<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const obj = {
            name: '123',
            age: 25,
        }
        for (let key in obj) {
            // console.log(key)
            // console.log(obj[key])
            // console.log(obj.key)
            // console.log(obj['key'])
        }

        // obj.key ==> obj['key']
        // obj[key] ==> 这里的key是一个变量,这个变量的值是name,age

        new Object()
        // 静态方法
        // Object.keys()  返回对象的所有属性名,它是一个数组
        console.log(Object.keys(obj))  //['name', 'age']
        // Object.values()  返回对象的所有属性值,它是一个数组
        console.log(Object.values(obj))  //['123', 25]

        // 语法: Object.assign(target, ...sources)
        // target: 目标
        // sources:源对象, 可以是一个或多个(右边)
        // 对象的浅拷贝
        // 把sources里面的属性拷贝给target
        const obj1 = {}
        const obj2 = {name: 'ssd', ggg: 34}
        const res = Object.assign(obj1, obj2)
        console.log(obj1)
        console.log(res)
        console.log(obj1 === res)  //true

        const obj3 = {
            a: 1,
        }
        const obj4 = {
            b: 1,
        }
        const obj5 = {
            c: 4,
        }
        Object.assign(obj4, obj3, obj5)
        console.log(obj4, obj3, obj5)
    </script>
</body>
</html>